package com.threeman.mapswaypoints1;

import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Matrix;

public class Images {

	private static Bitmap resizeImage(int resourceId, int newWidth, int newHeight, int rotation, Resources res)
	{
		// original Bitmap
        Bitmap bitmapOrig = BitmapFactory.decodeResource(res, resourceId);
        
        int width = bitmapOrig.getWidth();
        int height = bitmapOrig.getHeight();

        float scaleWidth = ((float) newWidth) / width;
        float scaleHeight = ((float) newHeight) / height;
        
        // matrix for the manipulation
        Matrix matrix = new Matrix();
        // resize the bit map
        matrix.postScale(scaleWidth, scaleHeight);
        // rotate the Bitmap
        matrix.postRotate(rotation);
		
        // recreate the new Bitmap
        Bitmap resizedBitmap = Bitmap.createBitmap(bitmapOrig, 0, 0, width, height, matrix, true);
        
		return resizedBitmap;
	}
	
}
